package com.wateray.ipassbook.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author wateray
 * 
 */
public class Subject implements Entity,Serializable{
	
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 1L;
	
	private   String   parentId;	 //	親収支科目ID         	
	private   String   subjectId;	//	収支科目ID         	
	private   String   ipassbookFlag;	 //	家計区分         	
	private   String   owner;	  //  	
	private   String   subjectFlag;	  //	収支区分         	
	private   String   fixVary;	//	固定変動区分         	
	private   String   name;	    //	名称         	
	private   int   viewOrder;	   //	表示順番         	
	private   String   visible;	//	表示可否区分         	
	private   String   memo;	 //	メモ         	
	private   Date   regeditDate;	 //	登録日付         	
	private   Date   updateDate;	//	更新日付       
	
	private List<Subject> childrenList;

	public Subject(){}
	
	/**
	 * @return the parentId
	 */
	public String getParentId() {
		return parentId;
	}

	/**
	 * @param parentId the parentId to set
	 */
	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	/**
	 * @return the subjectId
	 */
	public String getSubjectId() {
		return subjectId;
	}

	/**
	 * @param subjectId the subjectId to set
	 */
	public void setSubjectId(String subjectId) {
		this.subjectId = subjectId;
	}

	/**
	 * @return the ipassbookFlag
	 */
	public String getIpassbookFlag() {
		return ipassbookFlag;
	}

	/**
	 * @param ipassbookDiv the ipassbookFlag to set
	 */
	public void setIpassbookFlag(String ipassbookFlag) {
		this.ipassbookFlag = ipassbookFlag;
	}

	/**
	 * @return the owner
	 */
	public String getOwner() {
		return owner;
	}

	/**
	 * @param owner the owner to set
	 */
	public void setOwner(String owner) {
		this.owner = owner;
	}

	/**
	 * @return the subjectFlag
	 */
	public String getSubjectFlag() {
		return subjectFlag;
	}

	/**
	 * @param subjectDiv the subjectFlag to set
	 */
	public void setSubjectFlag(String subjectFlag) {
		this.subjectFlag = subjectFlag;
	}

	/**
	 * @return the fixVary
	 */
	public String getFixVary() {
		return fixVary;
	}

	/**
	 * @param fixVary the fixVary to set
	 */
	public void setFixVary(String fixVary) {
		this.fixVary = fixVary;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the viewOrder
	 */
	public int getViewOrder() {
		return viewOrder;
	}

	/**
	 * @param viewOrder the viewOrder to set
	 */
	public void setViewOrder(int viewOrder) {
		this.viewOrder = viewOrder;
	}

	/**
	 * @return the visible
	 */
	public String getVisible() {
		return visible;
	}

	/**
	 * @param visible the visible to set
	 */
	public void setVisible(String visible) {
		this.visible = visible;
	}

	/**
	 * @return the memo
	 */
	public String getMemo() {
		return memo;
	}

	/**
	 * @param memo the memo to set
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 * @return the regeditDate
	 */
	public Date getRegeditDate() {
		return regeditDate;
	}

	/**
	 * @param regeditDate the regeditDate to set
	 */
	public void setRegeditDate(Date regeditDate) {
		this.regeditDate = regeditDate;
	}

	/**
	 * @return the updateDate
	 */
	public Date getUpdateDate() {
		return updateDate;
	}

	/**
	 * @param updateDate the updateDate to set
	 */
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	/**
	 * @return the childrenList
	 */
	public List<Subject> getChildrenList() {
		return childrenList;
	}

	/**
	 * @param childrenList the childrenList to set
	 */
	public void setChildrenList(List<Subject> childrenList) {
		this.childrenList = childrenList;
	}


	/**
	 * @return if parentId != subjectId return true,else false <br/>     
	 */
	public boolean isChild() {
		return !(subjectId.equals(parentId));
	}  
	
	/**
	 * @return 
	 *  has children, return true;<br/>
	 *  hasn't children, return false;
	 */
	public boolean hasChild() {
		return childrenList != null && childrenList.size() != 0;
	}  


	/**
	 * @return if parentId = subjectId return true,else false <br/>    
	 */
	public boolean isParent() {
		return (subjectId.equals(parentId));
	}
	
	public String toString(){
//		StringBuffer sb = new StringBuffer();
//		sb.append("Subject [parentId=" + parentId);
//		sb.append(", subjectId=" + parentId);
//		sb.append(", name=" + name);
//		sb.append(" ]");
//		return sb.toString();
		return name;
	}

	@Override
	public String getEntityId() {
		// TODO Auto-generated method stub
		return subjectId;
	}

	@Override
	public String getEntityName() {
		// TODO Auto-generated method stub
		return name;
	}
}
